package com.company.cloud.club.modules.core.util;

import lombok.Data;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.ScopedProxyMode;
import org.springframework.stereotype.Component;
import org.springframework.web.context.annotation.RequestScope;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

@Component("buffgeApp")
@RequestScope(proxyMode = ScopedProxyMode.TARGET_CLASS)
@Data
public class App<T> {

    @Autowired
    private ApplicationContext c;

    @Resource
    private HttpServletRequest req;

    private AuthUser<T> authUser;
    private String userType;
    private boolean isLogin;
    private boolean isAdmin;
    private boolean isRoot;
    private boolean isDealer;
    private boolean isUser;

    private String testData;

    // 代理商ID
    private Integer dealerId;

    // 组织ID
    private Integer NId;

    // 课代表userId
    private Integer salesman;

    // 分享者userId
    private Integer shareUid;

    public boolean isWx() {
        String ua = req.getHeader("User-Agent");
        return Utils.isWx(ua);
    }

}